package fr.uniscol.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import fr.uniscol.dao.IEtablissementDao;
import fr.uniscol.dao.ILoginDao;
import fr.uniscol.model.BaseAnneeScolaire;
import fr.uniscol.model.IUniscolUser;
import fr.uniscol.model.SuperAdminUser;
import fr.uniscol.service.ILoginService;

@Service("loginService")
public class LoginServiceImpl implements ILoginService {
	
	@Autowired
	private ILoginDao loginDao;
	
	@Autowired
	private IEtablissementDao etablissementDao;
	
	public ILoginDao getLoginDao() {
		return loginDao;
	}

	public void setLoginDao(ILoginDao loginDao) {
		this.loginDao = loginDao;
	}

	public IEtablissementDao getEtablissementDao() {
		return etablissementDao;
	}

	public void setEtablissementDao(IEtablissementDao etablissementDao) {
		this.etablissementDao = etablissementDao;
	}

	@Override
	public IUniscolUser authentifierUser(String login, String password) {
		
        if(login.equals("root") && password.equals("root")){
            return new SuperAdminUser();
        }
        
		IUniscolUser user = loginDao.getUserWithPassword(login, password);
		
		return user;
	}
}
